var app = getApp()
export default{
  post(url,param){
    url = app.globalData.HOST_ADDRESS + url
    return new Promise(function (resolve, reject) {
      wx.request({
        method:"POST",
        url: url,
        data: param||{},
        header:{
          "content-type":"application/x-www-form-urlencoded"
        },
        success: (res) => {
          if(res.statusCode==200){
            resolve(res.data)
            return
          }
          reject(res)
        },
        fail: (res) => {
          reject(res)
        }
      })
    })
  },
  get(url,param){
    url = app.globalData.HOST_ADDRESS + url
    return new Promise(function (resolve, reject) {
      wx.request({
        url: url,
        data: param||{},
        success: (res) => {
          if(res.statusCode==200){
            resolve(res.data)
            return
          }
          reject(res)
        },
        fail: (res) => {
          reject(res)
        }
      })
    })
  }
}